package com.sfx.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sfx.domain.entity.Role;
import com.sfx.mapper.RoleMapper;
import com.sfx.service.RoleService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* Created with IntelliJ IDEA.
* Description:
* User: sfx
* Date: 2023-07-15
* Time: 16:38
*/
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService{

    /**
     * 根据userId查询当前用户角色信息
     * @param userId
     * @return
     */
    @Override
    public List<String> selectRolesByUserId(Long userId) {
        List<String> res = new ArrayList<>();
        //1.当前用户是超级管理员
        if(userId == 1L) {
            res.add("admin");
            return res;
        }
        return getBaseMapper().selectRolesByUserId(userId);
    }
}